package com.itheima.date;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @program: itheima-jdk8
 * @description:
 * @author: zhanghz001
 * @create: 2021-01-10 10:15
 **/
public class SimpleDateFormatDemo1 {
    static SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    
    public static void main(String[] args) {
        for (int i = 0; i < 30; i++) {
            new Thread(() -> {
                
                Date date = new Date();
                String format = format(date);
                System.out.println(format);
                Date date1 = parse(format);
                System.out.println(date1);
            }).start();
        }
    }
    
    private static String format(Date date) {
        String format = SimpleDateFormatDemo1.format.format(date);
        return format;
    }
    
    private static Date parse(String date) {
        Date parse = null;
        try {
            parse = format.parse(date);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return parse;
    }
}
